package com.shenmazong.servertalkseller.controller;

import com.shenmazong.servertalkseller.service.impl.TbSellerServiceImpl;
import com.shenmazong.utils.ResponseResult;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 田不平
 * @project demo-easytalk
 * @date 2020/9/15 11:16 AM
 * http://www.shenmazong.com
 */

@RestController
@Slf4j
@CrossOrigin
@Api(tags = "接口-销售管理微服务")
public class SellerController {

    @Autowired
    private TbSellerServiceImpl tbSellerService;

    /**
     * TODO doLogin 销售登录
     * @param userName
     * @param userPass
     * @return
     */
    @ApiOperation(value = "销售登陆", notes = "销售管理平台销售登陆")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name="userName", value = "用户名", dataType = "String", required=true),
            @ApiImplicitParam(name="userPass", value = "密码", dataType = "String", required=true)
    })
    @PostMapping(value = "/doLogin")
    public ResponseResult doLogin(@RequestParam("userName") String userName,
                                  @RequestParam("userPass") String userPass) {
        return tbSellerService.doSellerLogin(userName,userPass);
    }

    /**
     * TODO setUserPass 修改销售密码
     * @param userId
     * @param oldPass
     * @param newPass
     * @return
     */
    @ApiOperation(value = "修改销售密码", notes = "销售管理平台修改销售密码")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name="userId ", value = "销售编号", dataType = "int", required=true,example = "0"),
            @ApiImplicitParam(name="oldPass", value = "旧密码", dataType = "String", required=true),
            @ApiImplicitParam(name="newPass", value = "新密码", dataType = "String", required=true)
    })
    @PostMapping(value = "/setUserPass")
    public ResponseResult setUserPass(
            @RequestParam("userId") Integer userId,
            @RequestParam("oldPass") String oldPass,
            @RequestParam("newPass") String newPass) {
        return tbSellerService.setSellerPass(userId,oldPass,newPass);
    }

    /**
     * TODO getAllFinishClass 获取所有已经完成的课时
     * @return
     */
    @PostMapping(value = "/getFinishClassByPage")
    @ApiOperation(value = "获取所有已经完成的课时", notes = "销售管理平台获取所有已经完成的课时")
    @ApiOperationSupport(order = 1)
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name="userId", value = "销售编号", dataType = "int", required=true, example = "0"),
            @ApiImplicitParam(name="currentPage", value = "当前页", dataType = "int", required=true,example = "0"),
            @ApiImplicitParam(name="pageSize", value = "每页多少条", dataType = "int", required=true,example = "0")
    })
    public ResponseResult getFinishClassByPage(
            @RequestParam("userId") Integer userId,
            @RequestParam("currentPage") Integer currentPage,
            @RequestParam("pageSize") Integer pageSize
    ) {
        return tbSellerService.getFinishClassByPage(userId,currentPage,pageSize);
    }

    /**
     * TODO getAllWillClass 获取没有上完的课时
     * @return
     */
    @PostMapping(value = "/getWillClassByPage")
    @ApiOperation(value = "获取所有未完成的课时", notes = "销售管理平台获取所有未完成的课时")
    @ApiOperationSupport(order = 1)
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name="userId", value = "销售编号", dataType = "int", required=true, example = "0"),
            @ApiImplicitParam(name="currentPage", value = "当前页", dataType = "int", required=true,example = "0"),
            @ApiImplicitParam(name="pageSize", value = "每页多少条", dataType = "int", required=true,example = "0")
    })
    public ResponseResult getWillClassByPage(@RequestParam("userId") Integer userId,
                                          @RequestParam("currentPage") Integer currentPage,
                                          @RequestParam("pageSize") Integer pageSize) {
        return tbSellerService.getWillClassByPage(userId,currentPage,pageSize);
    }

    /**
     * TODO getClassFeeLogs 获取课时提成明细
     * @return
     */
    @PostMapping(value = "/getClassFeeRecordByPage")
    @ApiOperation(value = "获取课程提成明细", notes = "销售管理平台获取课程提成明细")
    @ApiOperationSupport(order = 1)
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name="userId", value = "销售编号", dataType = "int", required=true, example = "0"),
            @ApiImplicitParam(name="currentPage", value = "当前页", dataType = "int", required=true,example = "0"),
            @ApiImplicitParam(name="pageSize", value = "每页多少条", dataType = "int", required=true,example = "0")
    })
    public ResponseResult getClassFeeRecordByPage(
            @RequestParam("userId") Integer userId,
            @RequestParam("currentPage") Integer currentPage,
            @RequestParam("pageSize") Integer pageSize) {
        return tbSellerService.getClassFeeRecordByPage(userId,currentPage,pageSize);
    }

    /**
     * TODO getClassFeeByMonth 获取课时提成汇总（按月）
     * @return
     */
    @ApiOperation(value = "获取销售月结算提成列表", notes = "获取销售月结算提成列表")
    @ApiOperationSupport(order = 1)
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name="userId", value = "销售编号", dataType = "int", required=true, example = "0"),
            @ApiImplicitParam(name="currentPage", value = "当前页", dataType = "int", required=true,example = "0"),
            @ApiImplicitParam(name="pageSize", value = "每页多少条", dataType = "int", required=true,example = "0")
    })
    @PostMapping(value = "/getClassFeeByMonth")
    public ResponseResult getClassFeeByMonth(
            @RequestParam("userId") Integer userId,
            @RequestParam("currentPage") Integer currentPage,
            @RequestParam("pageSize") Integer pageSize
            ) {
        return null;
    }


    /**
     * TODO geClassFeeByMonth 获取所有自己管理的学生
     * @return
     */
    @ApiOperation(value = "获取所有管理的学生", notes = "销售管理平台获取所有管理的学生")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name="userId", value = "销售编号", dataType = "int", required=true, example = "0"),
    })
    @PostMapping(value = "/getStudentByPage")
    public ResponseResult getStudentByPage(@RequestParam("userId") Integer userId,
                                        @RequestParam("currentPage") Integer currentPage,
                                        @RequestParam("pageSize") Integer pageSize) {
        return tbSellerService.getStudentByPage(userId,currentPage,pageSize);
    }
}
